#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define ID_LENGTH 10
#define NAME_LENGTH 100
#define GENDER_LENGTH 20

int main()
{
    typedef struct {
        int id;
        char name[NAME_LENGTH];
        char gender[GENDER_LENGTH];
        int age;
    } student;

    int sample_count;
    while (scanf(" %d", &sample_count) != EOF) {
        int student_count;
        student *list;
        for (int i = 0; i < sample_count; i++) {
            scanf(" %d", &student_count);
            list = (student *) malloc(student_count * sizeof(student));
            for (int j = 0; j < student_count; j++) {
                scanf("%d %s %s %d", &list[j].id, list[j].name, list[j].gender, &list[j].age);
            }
            // printf("%d %s %s %d\n", list[0].id, list[0].name, list[0].gender, list[0].age);
        
            int target;
            scanf(" %d", &target);
            for (int j = 0; j < student_count; j++) {
                if(target == list[j].id)
                    printf("%d %s %s %d\n", list[j].id, list[j].name, list[j].gender, list[j].age);
            }
        }
    }

    return 0;
}